<?$this->load->view("/inc/header_inc")?>
   <?$this->load->view("/inc/nav_inc")?>
    <div class="content">
        <div class="header">
            <div class="stats">
			    <p class="stat"><span class="label label-info">5</span> Tickets</p>
			    <p class="stat"><span class="label label-success">27</span> Tasks</p>
			    <p class="stat"><span class="label label-danger">15</span> Overdue</p>
			</div>
            <h1 class="page-title">管理面板</h1>
            <ul class="breadcrumb">
	            <li><a href="/home">首页</a> </li>
	            <li class="active">监测点管理</li>
   		    </ul>
        </div>
        <div class="main-content">
            <div class="btn-toolbar list-toolbar">
                <?if($host['type']==USER_TYPE_ADMIN){?>
                <a href="/admin/user/addeditPlace" class="btn btn-success"><i class="fa fa-plus"></i>添加监测区域</a>
                <?}?>
               
                <div class="btn-group"></div>
            </div>
            <div class="row">
                <div class="col-sm-12 col-md-12">
                    <div class="panel panel-default">
                        <div class="panel-heading no-collapse">用户列表<span class="label label-warning"><?=$total?></span></div>
                        <table class="table table-bordered table-striped">
                            <thead>
                            <tr>
                                <th>ID</th>
                                <th>省份</th>
                                <th>监测区域名称</th>
                                <th>创建时间</th>
                                 <?if($host['type']==USER_TYPE_ADMIN){?>
                                <th>操作</th>
                                <?}?>
                            </tr>
                            </thead>
                            <tbody>
                            <?
                            foreach($list as $p) {
                                ?>
                                <tr>
                                    <td><?=$p['id']?></td>
                                    <td><?=$p['province']?></td>
                                    <td><?=$p['name']?></td>
                                    <td><?=$p['c_time']?></td>
                                 <?if($host['type']==USER_TYPE_ADMIN){?>

                                    <td>

                                        <a href="/admin/user/addeditPlace?id=<?=$p['id']?>" title="编辑监测区域"><i class="fa fa-pencil"></i></a>
                                        <a href="javascript:;"  data-id="<?=$p['id']?>" title="删除区域" data-name="<?=$p['name']?>" class="user-delete-btn" role="button"><i class="fa fa-trash-o"></i></a>
                                    </td>
                                <?}?>
                                    
                                </tr>
                            <?
                            }
                            ?>
                            </tbody>
                        </table>
                    </div>
                </div>
                <!--pagination start-->
                <div class="col-sm-12 col-md-12">
                    <ul class="pagination">
                          <li><a href="/admin/user/places/1">&laquo;</a></li>
                          <?
                            for($i=1;$i<=$lastpg;$i++){
                          ?>
                          <li><a href="/admin/user/places/<?=$i?>"><?=$i?></a></li>
                          <?
                            }
                          ?>
                          <li><a href="/admin/user/places/<?=$lastpg?>">&raquo;</a></li>

                    </ul>                   
                </div>
                <div class="col-sm-12 col-md-12">
                    <span>当前第<?=$page?>页，共<?=$lastpg?>页。</span>
                </div>
                <!--pagination end-->
            </div>
        </div>
			     

        <footer>
            <hr>               
            <p>© 2014 <a href="#" target="_blank">Portnine</a></p>
        </footer>
    </div>
    <div class="modal small fade" id="deleteModal" tabindex="-1" role="dialog" aria-labelledby="deleteModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h3 id="deleteModalLabel">删除用户</h3>
                </div>
                <div class="modal-body">
                    <p class="error-text"><i class="fa fa-warning modal-icon" ></i><span id="modal-delete-content"></span></p>
                </div>
                <div class="modal-footer">
                    <button class="btn btn-default" data-dismiss="modal"  aria-hidden="true">取消删除</button>
                    <button class="btn btn-danger" data-dismiss="modal" id="delete-user" id="delete-user" data-id="" >确定删除</button>
                </div>
            </div>
        </div>
    </div>
    <script src="/static/javascripts/jquery-1.11.3.min.js" type="text/javascript"></script>
    <script src="/static/javascripts/bootstrap.min.js"></script>
    <script type="text/javascript">
    $(function(){
        $(".user-delete-btn").click(function(){
            var id=$(this).data("id");
            var name=$(this).data("name");
            showDelete(id,"确认删除监测区域: "+name+" 吗?");
        });
        $("#delete-user").click(function(){
            var uid=$("#delete-user").data("id");
            $.post("/admin/user/deletePlace",
                {uid:uid},
                function(data)
                {
                    if(data.code==1)
                    {
                        window.location.reload();
                    }else {
                        alert(data.msg);
                    }
                },"json");

        });
    });
    function showDelete(id,content){
        // $('#deleteModal').modal('toggle');
        $('#deleteModal').modal('show');
        $("#modal-delete-content").text(content);
        $("#delete-user").attr("data-id",id);
    }
</script>
</body>
</html>
